//
//  FGPrefix.h
//  FGKit
//
//  Created by LWF on 2019/4/6.
//

#ifndef FGPrefix_h
#define FGPrefix_h


//APPConst
#import <FGKit/FGAPPConst.h>
#import <FGKit/JsonLog.h>

//weakSelf
#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;
#define SS(strongSelf)  __strong typeof(weakSelf) strongSelf = weakSelf;

#ifndef weakify
#if DEBUG
#if __has_feature(objc_arc)
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif

#ifndef strongify
#if DEBUG
#if __has_feature(objc_arc)
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif


/* push */
#define pushVC(_vc) ([self.navigationController pushViewController:_vc animated:YES])
#define popVC() ([self.navigationController popViewControllerAnimated:YES])


//输出日志
#ifdef DEBUG
//集成阿里云后 NSLog不打印
#define FGLog(format, ...) if ([JsonLog isLogEnable]){\
printf("class: <%p %s 第%d行 > method: %s  %s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] );\
}

//#define FGLog(...) NSLog(__VA_ARGS__)
//#define FGLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])

#else
#define FGLog(...)
#endif


#endif /* FGPrefix_h */
